//------------------------------------------------------------------------------
// Copyright (c) 2008 www.dnaide.com
// Licensed under the MIT (MIT-LICENSE.txt)
//------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace DNAide.Core
{
	public static partial class StringAide
	{

		/// <summary>
		/// Returns a copy of this String converted to Title Case, using the casing rules of the current culture
		/// </summary>
		/// <param name="value">Value</param>
		/// <returns>String</returns>
		public static String ToTitleCase(String value)
		{
			return ToTitleCase(value, CultureInfo.CurrentCulture);
		}


		/// <summary>
		/// Returns a copy of this String converted to Title Case
		/// </summary>
		/// <param name="value">Value</param>
		/// <param name="culture">Culture</param>
		/// <returns>String</returns>
		public static String ToTitleCase(String value, CultureInfo culture)
		{
			if (culture == null)
			{
				culture = CultureInfo.CurrentCulture;
			}
			
			value = CastAide.AsString(value, string.Empty, culture);
			if (value.Length < 1)
				return value;

			value = value.ToLower(culture);

			TextInfo ti = culture.TextInfo;

			return ti.ToTitleCase(value);
		}


		/// <summary>
		/// Returns a copy of this String converted to Title Case, using the casing rules of the invariant culture
		/// </summary>
		/// <param name="value">Value</param>
		/// <returns>String</returns>
		public static String ToTitleCaseInvariant(String value)
		{
			return ToTitleCase(value, CultureInfo.InvariantCulture);
		}

	}
}
